guint debug_enabled : 1;
guint forward_compatible : 1;
guint is_legacy : 1;
- guint use_es : 1;
+
+ int use_es;
GdkGLContextPaintData *paint_data;
} GdkGLContextPrivate;
static void
gdk_gl_context_init (GdkGLContext *self)
{
+ GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (self);
+
+ priv->use_es = -1;
}
/*< private >
/**
* gdk_gl_context_set_use_es:
* @context: a #GdkGLContext:
- * @use_es: whether the context should use OpenGL ES instead of OpenGL
+ * @use_es: whether the context should use OpenGL ES instead of OpenGL,
+ * or -1 to allow auto-detection
*
* Requests that GDK create a OpenGL ES context instead of an OpenGL one,
* if the platform and windowing system allows it.
*
* The @context must not have been realized.
*
+ * By default, GDK will attempt to automatically detect whether the
+ * underlying GL implementation is OpenGL or OpenGL ES once the @context
+ * is realized.
+ *
* You should check the return value of gdk_gl_context_get_use_es() after
* calling gdk_gl_context_realize() to decide whether to use the OpenGL or
* OpenGL ES API, extensions, or shaders.
*/
void
gdk_gl_context_set_use_es (GdkGLContext *context,
- gboolean use_es)
+ int use_es)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
g_return_if_fail (GDK_IS_GL_CONTEXT (context));
g_return_if_fail (!priv->realized);
- priv->use_es = !!use_es;
+ if (priv->use_es != use_es)
+ priv->use_es = use_es;
}
/**
g_return_val_if_fail (GDK_IS_GL_CONTEXT (context), FALSE);
- return priv->use_es;
+ if (!priv->realized)
+ return FALSE;
+
+ return priv->use_es > 0;
}
/**
priv->gl_version = epoxy_gl_version ();
+ if (priv->use_es < 0)
+ priv->use_es = !epoxy_is_desktop_gl ();
+
if (priv->use_es)
{
has_npot = priv->gl_version >= 20;